package bpmn.diagram.part;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;

import bpmn.diagram.providers.Bpmn_1_1ElementTypes;

/**
 * @generated
 */
public class Bpmn_1_1PaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createDefault1Group());
		paletteRoot.add(createTask2Group());
		paletteRoot.add(createEvents3Group());
		paletteRoot.add(createGateways4Group());
		paletteRoot.add(createLinks5Group());
		paletteRoot.add(createCompartment6Group());
	}

	/**
	 * Creates "Default" palette tool group
	 * @generated
	 */
	private PaletteContainer createDefault1Group() {
		PaletteGroup paletteContainer = new PaletteGroup(
				Messages.Default1Group_title);
		paletteContainer.setId("createDefault1Group"); //$NON-NLS-1$
		paletteContainer.setDescription(Messages.Default1Group_desc);
		paletteContainer.add(createDataObject1CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Task" palette tool group
	 * @generated
	 */
	private PaletteContainer createTask2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Task2Group_title);
		paletteContainer.setId("createTask2Group"); //$NON-NLS-1$
		paletteContainer.add(createDefaultTask1CreationTool());
		paletteContainer.add(createServiceTask2CreationTool());
		paletteContainer.add(createReceiveTask3CreationTool());
		paletteContainer.add(createSendTask4CreationTool());
		paletteContainer.add(createUserTask5CreationTool());
		paletteContainer.add(createScriptTask6CreationTool());
		paletteContainer.add(createAbstractTask7CreationTool());
		paletteContainer.add(createManualTask8CreationTool());
		paletteContainer.add(createReferenceTask9CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Events" palette tool group
	 * @generated
	 */
	private PaletteContainer createEvents3Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Events3Group_title);
		paletteContainer.setId("createEvents3Group"); //$NON-NLS-1$
		paletteContainer.add(createStart1CreationTool());
		paletteContainer.add(createEnd2CreationTool());
		paletteContainer.add(createIntermediate3CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Gateways" palette tool group
	 * @generated
	 */
	private PaletteContainer createGateways4Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Gateways4Group_title);
		paletteContainer.setId("createGateways4Group"); //$NON-NLS-1$
		paletteContainer.add(createInclusiveGateway1CreationTool());
		paletteContainer.add(createComplexGateway2CreationTool());
		paletteContainer.add(createParallelGateway3CreationTool());
		paletteContainer.add(createDataBasedExclusiveGateway4CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Links" palette tool group
	 * @generated
	 */
	private PaletteContainer createLinks5Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Links5Group_title);
		paletteContainer.setId("createLinks5Group"); //$NON-NLS-1$
		paletteContainer.add(createFlow1CreationTool());
		paletteContainer.add(createAssociation2CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Compartment" palette tool group
	 * @generated
	 */
	private PaletteContainer createCompartment6Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Compartment6Group_title);
		paletteContainer.setId("createCompartment6Group"); //$NON-NLS-1$
		paletteContainer.add(createPool1CreationTool());
		paletteContainer.add(createProcess2CreationTool());
		paletteContainer.add(createLane3CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDataObject1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.DataObject1CreationTool_title,
				Messages.DataObject1CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.DataObject_3006));
		entry.setId("createDataObject1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.DataObject_3006));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDefaultTask1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.DefaultTask1CreationTool_title,
				Messages.DefaultTask1CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3002));
		entry.setId("createDefaultTask1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createServiceTask2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ServiceTask2CreationTool_title,
				Messages.ServiceTask2CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3009));
		entry.setId("createServiceTask2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3009));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createReceiveTask3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ReceiveTask3CreationTool_title,
				Messages.ReceiveTask3CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3014));
		entry.setId("createReceiveTask3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3014));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSendTask4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.SendTask4CreationTool_title,
				Messages.SendTask4CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3015));
		entry.setId("createSendTask4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3015));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createUserTask5CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.UserTask5CreationTool_title,
				Messages.UserTask5CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3016));
		entry.setId("createUserTask5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3016));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createScriptTask6CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ScriptTask6CreationTool_title,
				Messages.ScriptTask6CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3017));
		entry.setId("createScriptTask6CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3017));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createAbstractTask7CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.AbstractTask7CreationTool_title,
				Messages.AbstractTask7CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3018));
		entry.setId("createAbstractTask7CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3018));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createManualTask8CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ManualTask8CreationTool_title,
				Messages.ManualTask8CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3019));
		entry.setId("createManualTask8CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3019));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createReferenceTask9CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ReferenceTask9CreationTool_title,
				Messages.ReferenceTask9CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Task_3020));
		entry.setId("createReferenceTask9CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Task_3020));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createStart1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Start1CreationTool_title,
				Messages.Start1CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Start_3003));
		entry.setId("createStart1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Start_3003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEnd2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.End2CreationTool_title,
				Messages.End2CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.End_3005));
		entry.setId("createEnd2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.End_3005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createIntermediate3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Intermediate3CreationTool_title,
				Messages.Intermediate3CreationTool_desc,
				Collections
						.singletonList(Bpmn_1_1ElementTypes.Intermediate_3004));
		entry.setId("createIntermediate3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Intermediate_3004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createInclusiveGateway1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.InclusiveGateway1CreationTool_title,
				Messages.InclusiveGateway1CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Inclusive_3010));
		entry.setId("createInclusiveGateway1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Inclusive_3010));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComplexGateway2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ComplexGateway2CreationTool_title,
				Messages.ComplexGateway2CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Complex_3011));
		entry.setId("createComplexGateway2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Complex_3011));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createParallelGateway3CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(Bpmn_1_1ElementTypes.Parallel_3012);
		types.add(Bpmn_1_1ElementTypes.Lane_3008);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ParallelGateway3CreationTool_title,
				Messages.ParallelGateway3CreationTool_desc, types);
		entry.setId("createParallelGateway3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Parallel_3012));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDataBasedExclusiveGateway4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.DataBasedExclusiveGateway4CreationTool_title,
				Messages.DataBasedExclusiveGateway4CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.DataBased_3013));
		entry.setId("createDataBasedExclusiveGateway4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.DataBased_3013));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createFlow1CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Flow1CreationTool_title,
				Messages.Flow1CreationTool_desc,
				Collections
						.singletonList(Bpmn_1_1ElementTypes.SequenceFlow_4001));
		entry.setId("createFlow1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.SequenceFlow_4001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createAssociation2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.Association2CreationTool_title,
				Messages.Association2CreationTool_desc,
				Collections
						.singletonList(Bpmn_1_1ElementTypes.Association_4002));
		entry.setId("createAssociation2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Association_4002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPool1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Pool1CreationTool_title,
				Messages.Pool1CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Pool_2003));
		entry.setId("createPool1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Pool_2003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createProcess2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Process2CreationTool_title,
				Messages.Process2CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Process_3001));
		entry.setId("createProcess2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Process_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createLane3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Lane3CreationTool_title,
				Messages.Lane3CreationTool_desc,
				Collections.singletonList(Bpmn_1_1ElementTypes.Lane_3007));
		entry.setId("createLane3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(Bpmn_1_1ElementTypes
				.getImageDescriptor(Bpmn_1_1ElementTypes.Lane_3007));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List<IElementType> elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List<IElementType> relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
